package com.bjsdzk.common.excel;

import com.bjsdzk.common.utils.RegExpUtils;

import java.util.List;
import java.util.Map;

public class ExcelFormatUtils {
    public static String format(Map<String, Object> titleHandlerMap, String value) {
        List<String> formats = RegExpUtils.find(value);
        for (String format : formats) {
            Object o = titleHandlerMap.get(format);
            value = value.replace(getOrigin(format), o.toString());
        }

        return value;
    }

    private static CharSequence getOrigin(String format) {
        return "${" + format + "}";
    }
}
